package com.restcloud.utils;

import com.restcloud.pojo.PersonalInformation.*;
import com.restcloud.pojo.Public.Code;
import com.restcloud.pojo.Public.Id;
import com.restcloud.pojo.Public.Value;

import java.util.ArrayList;
import java.util.List;

public class Error {

    public static void main(String[] args) {
        PRPA_IN201306UV02 prpa = new PRPA_IN201306UV02();
        prpa.setXmlns("urn:hl7-org:v3");
        prpa.setITSVersion("XML_ 1.0");
        prpa.setXmlnsXsi("http://www.w3.org/2001/XMLSchema-instance");
        prpa.setSchemaLocation("urn:hl7-org:v3 ../multicacheschemas/PRPA_IN201306UV02.xsd");

        Id id = new Id();
        id.setExtension("8D73520B-D489-4B70-8F4B-7B5C2D7961B5");
        prpa.setId(id);
        /**
         * 创建时间
         */
        Value creationTime = new Value(TimeUtil.dateTime());
        prpa.setCreationTime(creationTime);

        Id interactionId = new Id();
        interactionId.setRoot("2.16.840.1.113883.1.6");
        interactionId.setExtension("PRPA_IN201306UV02");
        prpa.setInteractionId(interactionId);

        prpa.setProcessingCode(new Code("P"));

        prpa.setProcessingModeCode(new Code());

        prpa.setAcceptAckCode(new Code("AL"));

        Receiver receiver = new Receiver();
        receiver.setTypeCode("RCV");
        receiver.setTelecom(new Code());
        Device device = new Device();
        device.setClassCode("DEV");
        device.setDeterminerCode("INSTANCE");
        List<Id> idItem1 = new ArrayList<>();
        idItem1.add(new Id("2.16.156.10011.0.1.1",""));
        device.setId(idItem1);
        receiver.setDevice(device);
        prpa.setReceiver(receiver);

        Receiver sender = new Receiver();
        sender.setTypeCode("SND");
        sender.setTelecom(new Code());
        Device device1 = new Device();
        device1.setClassCode("DEV");
        device1.setDeterminerCode("INSTANCE");
        List<Id> idItem2 = new ArrayList<>();
        idItem2.add(new Id("2.16.156.10011.0.1.2",""));
        device1.setId(idItem2);
        sender.setDevice(device1);
        prpa.setSender(sender);

        Receiver acknowledgement = new Receiver();
        acknowledgement.setTypeCode("AE");
        Value targetMessage = new Value();
        Id tarId =new Id();
        tarId.setRoot("2.16.156.10011.0");
        tarId.setExtension("22a0f9e0-4454-11dc-a6be-3603d6866807");
        targetMessage.setId(tarId);
        acknowledgement.setTargetMessage(targetMessage);
        List<Value> textList = new ArrayList<>();
        //textList.add(new Value(new Value("XXX 原因，失败")));
        textList.add(new Value(new Value("未查询到数据")));
        acknowledgement.setAcknowledgementDetail(textList);
        prpa.setAcknowledgement(acknowledgement);

        Device controlActProcess = new Device();
        controlActProcess.setClassCode("CACT");
        controlActProcess.setMoodCode("EVN");
        Code code = new Code("PRPA_TE201306UV02","2.16.840.1.113883.1.6");
        controlActProcess.setCode(code);
        Id queryAck = new Id();
        queryAck.setQueryId(new Id("2.16.156.10011.0","22a0f9e0-4454-11dc-a6be-3603d6866807"));
        queryAck.setQueryResponseCode(new Code("NF"));
        controlActProcess.setQueryAck(queryAck);
        prpa.setControlActProcess(controlActProcess);

        String s = XmlUtil.beanToXml(prpa, PRPA_IN201306UV02.class, "GBK");
        System.out.println(s);
    }
}
